import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { JsonResult } from '../model/JsonResult';
import * as gc from 'src/app/global/const';

@Injectable({
  providedIn: 'root'
})
export class TableStyleService {

  private path_pre = 'tableStyle';

  private url = {
    'deleteByPrimaryKey':gc.BACKEND_SERVER_ROOT + '/' + this.path_pre,
    'selectByPrimaryKey':gc.BACKEND_SERVER_ROOT + '/' + this.path_pre,
    'selectAll':gc.BACKEND_SERVER_ROOT + '/' + this.path_pre + '/a',
    'saveOne':gc.BACKEND_SERVER_ROOT + '/' + this.path_pre,
    'selectByTableName':gc.BACKEND_SERVER_ROOT + '/' + this.path_pre + '/selectByTableName',
  }
  constructor(
    private http:HttpClient
  ) { }

  deleteByPrimaryKey(iid:number):Observable<JsonResult>{
    const url = this.url.deleteByPrimaryKey + '/' + iid;
    return this.http.delete<JsonResult>(url);
  }

  selectByPrimaryKey(iid:number):Observable<JsonResult>{
    const url = this.url.selectByPrimaryKey + '/' + iid;
    return this.http.get<JsonResult>(url);
  }

  selectByTableName(tableName:string):Observable<JsonResult>{
    const url = this.url.selectByTableName + '/' + tableName;
    return this.http.get<JsonResult>(url);
  }

  selectAll():Observable<JsonResult>{
    return this.http.get<JsonResult>(this.url.selectAll);
  }

  saveOne(record:TableStyle):Observable<JsonResult>{
    return this.http.post<JsonResult>(this.url.saveOne,record);
  }



}


// Author：chanchaw
// Generator Version：1.0 - 2019年11月16日 16点46分
// This Model Created：Tue Jan 07 2020 14:44:04 GMT+0800 (中国标准时间)
export class TableStyle{
  iid:number;
  table_name:string;
  field_name:string;
  text:string;
  seq:number;
  visible:boolean;
  immutable:boolean;
  bool_column:boolean;
  width_primeng_str:string;
  align_header:string;
  align_cell:string;
  tick_pipe:boolean;
  cn_pipe:boolean;
  access_pipe:boolean;
  create_time:Date;
  width_zorro:number;
  width_primeng:number;
  get_url:string;
  width_percent:number;
  width_percent_str:string;
  opts:string;
  date_pipe:boolean;
  date_formatter:string;
  ctl_type:string;
  generate_formula:string;
  digit:number;
  statistics:boolean;
  tease:string;
}
